package com.mars.algorithm.pattern.singleton;

/**
 * 单例模式--静态内部类模式
 *
 * 线程安全
 * 只有在掉用getInstance的时候会初始化SingletonContext的singleton
 * 启动的时候，在加载Singleton4的时候不会加载SingletonContext的singleton
 */
public class Singleton4 {


    private static class SingletonContext {
        private static Singleton4 singleton = new Singleton4();
    }

    public static Singleton4 getInstance() {
        return SingletonContext.singleton;
    }

}
